/****************************************************************
* Copyright (c) 2006-2021 Jingjia Micro Co., Ltd.
*
* File    :   gp_timer.h
* Author  :   luomin1249
* Date    :   2021/08/03
* Desc    :
* Other   :
*              
* History:
* Date        Modifier       Content 
*****************************************************************/
#ifndef __TIMER_H__
#define __TIMER_H__

#include <signal.h> 
#include <time.h> 

#include "object.h"

typedef struct gp_timer
{
    timer_t id;
    char name[32];
    struct itimerspec it;
    struct sigevent evp; 
    int (*start)(struct gp_timer *timer);
    int (*stop)(struct gp_timer *timer);
    int (*gettime)(struct gp_timer *timer, struct itimerspec *curr_value);
} gp_timer_t;

gp_timer_t *create_timer(void (*handle)(union sigval v), \
                        struct itimerspec it, char *name, void *data);

int delete_timer(gp_timer_t *timer);

#endif